﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using System.Web;
using Microsoft.AspNetCore.Mvc;
using YiSha.Util;
using YiSha.Util.Model;
using YiSha.Entity;
using YiSha.Model;
using YiSha.Admin.Web.Controllers;
using YiSha.Entity.TestManage;
using YiSha.Business.TestManage;
using YiSha.Model.Param.TestManage;

namespace YiSha.Admin.Web.Areas.TestManage.Controllers
{
    /// <summary>
    /// 创 建：admin
    /// 日 期：2021-07-12 17:00
    /// 描 述：控制器类
    /// </summary>
    [Area("TestManage")]
    public class BankController :  BaseController
    {
        private BankBLL bankBLL = new BankBLL();

        #region 视图功能
        [AuthorizeFilter("test:bank:view")]
        public ActionResult BankIndex()
        {
            return View();
        }

        public ActionResult BankForm()
        {
            return View();
        }
        #endregion

        #region 获取数据
        [HttpGet]
        [AuthorizeFilter("test:bank:search")]
        public async Task<ActionResult> GetListJson(BankListParam param)
        {
            TData<List<BankEntity>> obj = await bankBLL.GetList(param);
            return Json(obj);
        }

        [HttpGet]
        [AuthorizeFilter("test:bank:search")]
        public async Task<ActionResult> GetPageListJson(BankListParam param, Pagination pagination)
        {
            TData<List<BankEntity>> obj = await bankBLL.GetPageList(param, pagination);
            return Json(obj);
        }

        [HttpGet]
        public async Task<ActionResult> GetFormJson(long id)
        {
            TData<BankEntity> obj = await bankBLL.GetEntity(id);
            return Json(obj);
        }
        #endregion

        #region 提交数据
        [HttpPost]
        [AuthorizeFilter("test:bank:add,test:bank:edit")]
        public async Task<ActionResult> SaveFormJson(BankEntity entity)
        {
            TData<string> obj = await bankBLL.SaveForm(entity);
            return Json(obj);
        }

        [HttpPost]
        [AuthorizeFilter("test:bank:copy,test:bank:copy")]
        public async Task<ActionResult> CopyFormJson(BankEntity entity)
        {
            TData<string> obj = await bankBLL.CopyForm(entity);
            return Json(obj);
        }

        [HttpPost]
        [AuthorizeFilter("test:bank:import,test:bank:import")]
        public async Task<ActionResult> ImportFormJson(BankEntity entity)
        {
            TData<string> obj = await bankBLL.ImportForm(entity);
            return Json(obj);
        }

        [HttpPost]
        [AuthorizeFilter("test:bank:delete")]
        public async Task<ActionResult> DeleteFormJson(string ids)
        {
            TData obj = await bankBLL.DeleteForm(ids);
            return Json(obj);
        }
        #endregion
    }
}
